/*
 * Copyright 2018-2019 KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain menu_text_color copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.gzwanchuang.xhgj.bridge.request;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.gzwanchuang.xhgj.bridge.data.repository.HttpRequestManager;
import com.gzwanchuang.xhgj.proto.Bank;
import com.gzwanchuang.xhgj.proto.Index;
import com.gzwanchuang.xhgj.proto.Information;
import com.gzwanchuang.xhgj.proto.MemberOuterClass;
import com.gzwanchuang.xhgj.proto.Merchantservice;
import com.gzwanchuang.xhgj.proto.Statistics;

import java.util.List;

/**
 * 音乐资源  RequestViewModel
 * <p>
 * TODO tip：RequestViewModel 通常按业务划分
 * 一个项目中通常存在多个 RequestViewModel
 * 对 Jetpack ViewModel 的知识点感兴趣可详见 https://xiaozhuanlan.com/topic/6257931840
 * <p>
 * Create by KunMinX at 19/10/29
 */
public class HomeRequestViewModel extends ViewModel {

    private MutableLiveData<String> errorString;  // 错误信息的返回
    private MutableLiveData<String> resultString;
    private MutableLiveData<Index.get_show_list> showList;  // 获取banner列表
    private MutableLiveData<List<Statistics.trading>> tradings;  // 获取账单列表
    private MutableLiveData<List<Bank.bank>> bankList;  // 获取账单列表
    private MutableLiveData<List<Information.DetailInfo>> DetailInfos;  // 获取账单列表
    private MutableLiveData<Bank.bank> bank;
    private MutableLiveData<Statistics.trading> tradingDetail;
    private MutableLiveData<Merchantservice.bind> bind;
    private MutableLiveData<MemberOuterClass.created_order> order;
    private MutableLiveData<List<Bank.bank>> banks;  // 获取支持银行卡


    public MutableLiveData<List<Bank.bank>> getBanks()
    {
        if (banks == null) {
            banks = new MutableLiveData<>();
        }
        return banks;
    }
    public MutableLiveData<Merchantservice.bind> getBind()
    {
        if (bind == null) {
            bind = new MutableLiveData<>();
        }
        return bind;
    }


    public MutableLiveData<MemberOuterClass.created_order> getOrder()
    {
        if (order == null) {
            order = new MutableLiveData<>();
        }
        return order;
    }



    public MutableLiveData<List<Bank.bank>> getBankList() {
        if (bankList == null) {
            bankList = new MutableLiveData<>();
        }
        return bankList;
    }
    public MutableLiveData<List<Information.DetailInfo>> getDetailInfos() {
        if (DetailInfos == null) {
            DetailInfos = new MutableLiveData<>();
        }
        return DetailInfos;
    }




    public MutableLiveData<Statistics.trading> getTradingDetail() {
        if (tradingDetail == null) {
            tradingDetail = new MutableLiveData<>();
        }
        return tradingDetail;
    }

    public MutableLiveData<Bank.bank> getBank() {
        if (bank == null) {
            bank = new MutableLiveData<>();
        }
        return bank;
    }

    public MutableLiveData<String> getErrorString() {
        if (errorString == null) {
            errorString = new MutableLiveData<>();
        }
        return errorString;
    }


    public MutableLiveData<String> getResultString() {
        if (resultString == null) {
            resultString = new MutableLiveData<>();
        }
        return resultString;
    }


    public MutableLiveData<Index.get_show_list> getShowList() {
        if (showList == null) {
            showList = new MutableLiveData<>();
        }
        return showList;
    }

    public MutableLiveData<List<Statistics.trading>> getTradings() {
        if (tradings == null) {
            tradings = new MutableLiveData<>();
        }
        return tradings;
    }


    public void getbanner() {
        HttpRequestManager.getInstance().getBanner(getShowList(), getErrorString());
    }


    public void get_trading_list(int page, String typeNumber,String StatusNumber, String month, String dayFirst, String dayEnd) {
        HttpRequestManager.getInstance().get_trading_list(getTradings(), getErrorString(), page, typeNumber,StatusNumber, month, dayFirst, dayEnd);
    }

    public void get_bank(String type, String form) {   // 获取结算卡 单个
        HttpRequestManager.getInstance().get_bank(getBank(), getErrorString(), type, form);

    }

    public void get_xin_yong_bank(String type, String form) {   // 获取信用卡  多个
        HttpRequestManager.getInstance().get_bank_list(getBankList(), getErrorString(), type, form);
    }

    public void get_trading_detail(String id, String time) {
        HttpRequestManager.getInstance().get_trading_detail(getTradingDetail(), getErrorString(), id, time);
    }

    public void get_support(String type, String form) {
        HttpRequestManager.getInstance().get_support(getBanks(), getErrorString(),type,form);
    }

    public void unbind_card(String id) {
        HttpRequestManager.getInstance().unbind_card(getResultString(), getErrorString(),id);
    }

    public void get_sn() {
        HttpRequestManager.getInstance().get_sn(getBind(), getErrorString());
    }

    public void informationIndex() {
        HttpRequestManager.getInstance().informationIndex(getDetailInfos(), getErrorString());
    }

    public void created_order() {
        HttpRequestManager.getInstance().created_order(getOrder(), getErrorString());
    }
}
